home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_08_11
/
8n11103a
< prev
next >
Wrap
Text File
|
1990-08-07
|
1KB
|
49 lines
***********
Listing 3
#include <stdio.h>
typedef struct
{
char fname[25];
char lname[25];
} REC;
main()
{
REC rec, *recptr;
char charstr[25], *cptr;
int i;
/***********/
strcpy(rec.fname, "Stanley");
strcpy(rec.lname, "Cohen");
recptr = &rec;
cptr = recptr; /*** value of recptr is assigned to cptr
NO cast ***/
i = 0;;
while( charstr[i++] = *cptr++); /*** pointer arithmetic
on cptr ***/
puts(charstr); /*** first name is output to screen
***/
cptr = recptr;
printf("\n\address pointed to by cptr -> %d", cptr);
printf("\naddress pointed to by recptr -> %d", recptr);
cptr++;
recptr++;
printf("\n\naddress pointed to by cptr -> %d", cptr);
printf("\naddress pointed to by recptr -> %d", recptr);
}
**********